<template>
	<view class="salesType_box">
		<view class="tab_nav">
			<nav-bar nav_btn="back" @onPicker="getPicker" :title="title" :showPicker="showPicker" :color="color"
				:list="list" :auto_img="image" :background="background"></nav-bar>
		</view>
		<view class="goods_list_box w100 flexjus" v-for="(item,index) in salesData.info" :key="index">
			<view class="flex">
				<view class="left_goods_img">
					<image class="w100 h100" :src="item.image_src" mode=""></image>
				</view>
				<view class="left_goods_name family f500 s26">
					{{item.title}}
				</view>
			</view>
			<view class="right_price">
				<view class="top_price_txt s32 f500 family">
					<text class="s24">￥</text>{{item.price}}
				</view>
				<view class="bottom_number_txt s22 family f500 txtali">
					共{{item.number}}件
				</view>
			</view>
		</view>
		<view class="shouhou_box">
			<view class="top_image_box"></view>
		</view>
		<view class="bottom_box">
			
			<view class="list_box flexjus" @click="goSales('repair',salesData.list[0])" v-if="list1.after_id">
				<view class="left_box flex">
					<view class="left_icon"></view>
					<view class="left_txt s32 familytow fblod">
						维修
					</view>
				</view>
				<view class="right_box flex">
					<view class="right_date s22 family f500">
						{{salesData.list[0].end}}时 前可申请
					</view>
					<view class="right_icon"></view>
				</view>
			</view>
			<view class="list_box flexjus" @click="goSales('returnGoods',salesData.list[1])"  v-if="list2.after_id">
				<view class="left_box flex">
					<view class="left_icon_two"></view>
					<view class="left_txt s32 familytow fblod">
						退货
					</view>
				</view>
				<view class="right_box flex" style="margin-top: 36upx;">
					<view>
						<view class="right_date s22 family f500">
							{{salesData.list[1].end}} 时 前可申请
						</view>
						<view class="tuihuo_txt s20 family f500">
							支持七天无理由退货
						</view>
					</view>
					<view class="right_icon"></view>
				</view>
			</view>
			<view class="list_box flexjus" @click="goSales('exchange',salesData.list[2])"  v-if="list3.after_id">
				<view class="left_box flex">
					<view class="left_icon_three"></view>
					<view class="left_txt s32 familytow fblod">
						换货
					</view>
				</view>
				<view class="right_box flex">
					<view class="right_date s22 family f500">
						{{salesData.list[2].end}} 时 前可申请
					</view>
					<view class="right_icon"></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '选择售后类型',
				image: '../static/tab_jian.png',
				color: 'black',
				background: '#ffffff',
				list: [],
				showPicker: false,
				salesData: {},
				list1: {},
				list2: {},
				list3: {}
			}
		},
		onLoad(options) {
			this.list.unshift({
				shopname: '选择售后类型',
				id: 122
			})
			this.getOrderData(options.id)
		},
		methods: {
			getOrderData(id) {
				this.$request({
					url: 'refund/get_refund_info',
					method: 'POST',
					data: {
						order_id: id
					}
				}).then(res => {
					let data = new Date()
					this.salesData = res.data.data;
					this.salesData.list.forEach(item => {
						if(item.after_id == 1) {
							this.list1 = item
						} else if(item.after_id == 2) {
							this.list2 = item
						} else if(item.after_id == 3) {
							this.list3 = item
						}
						item.current_time = new Date(data).valueOf()
						item.end_time = new Date(item.end).valueOf()
					})
				})
			},
			goSales(type, list) {
				let url = ''
				if (list.end_time <= list.current_time) {
					this.$wanlshop.msg('已过售后时间')
				} else {
					if (type == 'repair') {
						url = './repair?data=' + JSON.stringify(this.salesData.info)
					} else if (type == 'returnGoods') {
						url = './returnGoods?data=' + JSON.stringify(this.salesData.info)
					} else if (type == 'exchange') {
						url = './exchange?data=' + JSON.stringify(this.salesData.info)
					}
					uni.navigateTo({
						url: url
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.salesType_box {
		overflow: hidden;

		.tab_nav {
			background-color: #FFFFFF;
		}

		.goods_list_box {
			height: 184upx;
			background-color: #FFFFFF;
			padding-left: 32upx;
			padding-right: 32upx;
			box-sizing: border-box;

			.left_goods_img {
				width: 88upx;
				height: 88upx;
				background: #454545;
				border-radius: 8upx;
				margin-top: 56upx;
			}

			.left_goods_name {
				width: 356rpx;
				height: 72rpx;
				color: #333333;
				margin-left: 26upx;
				margin-top: 64upx;
				letter-spacing: 0;
				overflow: hidden;
				display: -webkit-box;
				text-overflow: ellipsis;
				-webkit-line-clamp: 2;
				-webkit-box-orient: vertical;
			}

			.right_price {
				margin-top: 64upx;

				.top_price_txt {
					color: #000000;
				}

				.bottom_number_txt {
					color: #666666;
				}
			}
		}

		.shouhou_box {
			padding-left: 32upx;
			padding-right: 32upx;
			box-sizing: border-box;
			margin-top: 26upx;

			.top_image_box {
				width: 208upx;
				height: 54upx;
				background-image: url('');
				background-size: 100% 100%;
			}
		}

		.bottom_box {
			width: 686upx;
			background: #FFFFFF;
			border-radius: 24upx;
			margin: 18upx auto;
			margin-bottom: 0;
			padding: 0upx 20upx 0 40upx;
			box-sizing: border-box;

			.list_box {
				height: 120upx;
				border-bottom: 2upx solid #F4F4F4;

				.left_box {
					margin-top: 38upx;

					.left_icon {
						width: 32upx;
						height: 32upx;
						background-image: url('');
						background-size: 100% 100%;
						margin-top: 6upx;
					}

					.left_icon_two {
						width: 32upx;
						height: 32upx;
						background-image: url('');
						background-size: 100% 100%;
						margin-top: 6upx;
					}

					.left_icon_three {
						width: 32upx;
						height: 32upx;
						background-image: url('');
						background-size: 100% 100%;
						margin-top: 6upx;
					}

					.left_txt {
						color: #000000;
						margin-left: 12upx;
					}
				}

				.right_box {
					margin-top: 46upx;

					.right_date {
						color: #666666;
					}

					.tuihuo_txt {
						color: #EB8787;
						text-align: right;
					}

					.right_icon {
						width: 20upx;
						height: 20upx;
						background-image: url('');
						background-size: 100% 100%;
						margin-top: 8upx;
						margin-left: 32upx;
					}
				}
			}
		}
	}
</style>
<style>
	page {
		background-color: #F4F5F9;
	}
</style>
